package com.credit.jumu.calculator.utils;

import android.app.Activity;

import com.credit.jumu.calculator.R;

import java.util.Date;

public class MonitorOnBack {
    private int timeTag = 0;
    private long timeOne = 0;
    private long timeTwo = 0;

    public void onBack(Activity baseActivity) {
        Date date = new Date();
        if (timeTag == 0) {
            timeOne = date.getTime();
            timeTag = 1;
			ToastUtil.showShortToast("再点击一下退出" + baseActivity.getString(R.string.app_name));
           // baseActivity.alertMessage("再点击一下退出" + baseActivity.getString(R.string.app_name));
        } else if (timeTag == 1) {
            timeTwo = date.getTime();
            if (timeTwo - timeOne <= 2500) {
                timeTag = 0;
                baseActivity.finish();
            } else {
                timeTag = 1;
                timeOne = date.getTime();
				ToastUtil.showShortToast("再点击一下退出" + baseActivity.getString(R.string.app_name));
                //baseActivity.alertMessage("再点击一下退出" + baseActivity.getString(R.string.app_name));
            }
        }
    }
}
